<!--
笔记列表
 add by yyp 2019-05-25
-->
<template lang="pug">
  keep-alive
    kalix-table(bizKey="Note" title='笔记列表' ref="kalixTable"
    v-bind:tableFields="tableFields"
    v-bind:targetURL="NoteURL"
    v-bind:bizDialog="noteDialog"
    v-bind:btnList="noteBtnList"
    v-bind:toolbarBtnList="toolbarBtnList"
    bizSearch="noteSearch")
      template(slot="tableColumnSlot")
        el-table-column(prop="userName" label="用户名称" align="center")
        el-table-column(prop="cname" label="课程" align="center")
        el-table-column(prop="noteTitle" label="笔记标题" align="center")
        el-table-column(prop="noteContent" label="笔记详情" align="center")
        el-table-column(prop="noteUpcounts" label="笔记点赞数量" align="center")
        el-table-column(prop="creationDate" label="笔记日期" align="center")
        el-table-column(prop="noteEnclosure" label="笔记附件")
          template(slot-scope="scope")
            div(v-for="img in getArray(scope.row.noteEnclosure)")
              img(v-bind:src="img" width="60" height="60" alt="" style="float:left; margin-right: 8px")
</template>

<script type="text/ecmascript-6">
  import {NoteURL} from '../../config.toml'
  import {noteConfigBtnList} from './config'
  import KalixTable from '../../../../../components/corelib/components/common/baseTable'

  export default {
    name: 'kalix-mooc-note',
    components: {KalixTable},
    data() {
      return {
        NoteURL: NoteURL,
        tableFields: [
          {prop: 'userName', label: '用户名称'},
          {prop: 'cname', label: '课程名称'},
          {prop: 'noteTitle', label: '笔记标题'},
          {prop: 'noteContent', label: '笔记详情'},
          {prop: 'noteEnclosure', label: '笔记附件'},
          {prop: 'noteUpcounts', label: '笔记点赞数量'}
        ],
        noteDialog: [
          {id: 'add', dialog: 'noteAdd'},
          {id: 'edit', dialog: 'noteEdit'},
          {id: 'view', dialog: 'noteView'}
        ],
        noteBtnList: noteConfigBtnList,
        toolbarBtnList: [
          {id: 'add', isShow: true, title: '添加', icon: 'icon-pinleizengjia', isPermission: true}
        ]
      }
    },
    methods: {
      dataFormat(val) {
        let d = new Date(val)
        return this.$M_FormatDate(d, 'yyyy-MM-dd')
      },
      getArray(val) {
        return val.split(',')
      }
    }
  }
</script>

<style scoped lang="stylus">

</style>
